﻿
//经销商联系人
var columns =
            [
                { display: 'Key', name: 'Id', type: 'text', hide: 1 },
                { display: 'ClientId', name: 'ClientID', type: 'text', hide: 1 },
                { display: '姓名', name: 'LinkManNmae', mintWidth: 80, width: 120 },
                { display: '性别', name: 'SexName', mintWidth: 60, width: 80 },
                { display: '证件类型', name: 'CredentialsTypeName', mintWidth: 100, width: 100 },
                { display: '证件号码', name: 'CredentialsNo', mintWidth: 80, width: 100 },
                { display: '所在部门', name: 'Department', mintWidth: 80, width: 100 },
                { display: '职务', name: 'CurrentJob', mintWidth: 80, width: 100 },
                { display: '业务负责', name: 'BusinessScope', mintWidth: 80, width: 100 },
                { display: '手机', name: 'MobilePhone', mintWidth: 80, width: 100 },
                { display: '座机电话', name: 'StudioCamera', mintWidth: 80, width: 100 }
             ];

var manager;
//init controls
$(document).ready(function () {
   // initligerGrid();
});

function initligerGrid() {
    manager = null;
    manager = $("#ClitentLinksGrid").ligerGrid({
        columns: columns,
       // title: '经销商联系人列表',//不进行gridview的行编辑，进行弹出，所以可以添加标题// 不能要标题，修改的BUG，不在ligerui.min.js文件中，所以这个BUG还是存在
        showTitle: false,
        width: '100%',
        enabledSort: true,
        //enabledEdit: true,
        checkbox: false,
        rownumbers: true,
//        toolbar: { items: [
//                                    { text: '经销商联系人列表' },
//                                    { text: '增加', click: dialogAdd, icon: 'add' },
//                                    { line: true },
//                                    { text: '修改', click: modifyOperation, icon: 'modify' },
//                                    { line: true },
//                                    { text: '删除', click: deleteOperation, img: '../Content/images/delete.gif' }
//                                    ]
//        },
       // isChecked: f_isChecked, onCheckRow: f_onCheckRow, onCheckAllRow: f_onCheckAllRow,
         url: "../Client/GetClientLinksByClient?clientId=" + $("#Id").val() + "&rand=" + Math.random()
    });
}
////add
//function dialogAdd() {
//var billId = $("#Id").val();
//$.ligerDialog.open({ url: '../Client/AddLink?clientId=' + billId, height: getDialogHeight()+40, width: getDialogWidth()+30,
//        isResize: true, isHidden: false
//    });
//}

////delete
//function deleteOperation() {
//    var row = manager.getSelectedRow();
//    var ids = checkedCustomer.join(',');
//    if (ids != null && ids != undefined && $.trim(ids).length > 0) {
//        $.ligerDialog.confirm('确定要删除吗？', function (yes) {
//            if (yes) {

//                $.get("../Client/DeleteLinks?clientLinkIds=" + ids, {}, function (data) {
//                        if (data != undefined && data == "9") {
//                            manager.deleteSelectedRow();
//                            initligerGrid();

//                        }
//                    });

//            }
//        });
//    }
//    else {
//        if (!row) { $.ligerDialog.success('请选择需要删除行！'); return; }
//    } 
//}
////update 
//function modifyOperation() {
//    var row = manager.getSelectedRow();
//    if (!row) {
//        $.ligerDialog.success('请选择要编辑的行!'); return;
//    }
//    $.ligerDialog.open({ url: '../Client/AddLink?type=edit&clientId=' + row.Id, height: getDialogHeight(), width: getDialogWidth(), isResize: true, isHidden: false
//    });
//}



////======================================================
//function f_onCheckAllRow(checked) {
//    for (var rowid in this.records) {
//        if (checked)
//            addCheckedCustomer(this.records[rowid]['Key']);
//        else
//            removeCheckedCustomer(this.records[rowid]['Key']);
//    }
//}
///*
//该例子实现 表单分页多选
//即利用onCheckRow将选中的行记忆下来，并利用isChecked将记忆下来的行初始化选中
//*/

//var checkedCustomer = [];
//function findCheckedCustomer(CustomerID) {
//    for (var i = 0; i < checkedCustomer.length; i++) {
//        if (checkedCustomer[i] == CustomerID) return i;
//    }
//    return -1;
//}
//function addCheckedCustomer(CustomerID) {
//    if (findCheckedCustomer(CustomerID) == -1)
//        checkedCustomer.push(CustomerID);
//}
//function removeCheckedCustomer(CustomerID) {
//    var i = findCheckedCustomer(CustomerID);
//    if (i == -1) return;
//    checkedCustomer.splice(i, 1);
//}
//function f_isChecked(rowdata) {
//    if (findCheckedCustomer(rowdata.CustomerID) == -1)
//        return false;
//    return true;
//}
//function f_onCheckRow(checked, data) {
//    if (checked) addCheckedCustomer(data.Id);
//    else removeCheckedCustomer(data.Id);
//}
//function f_getChecked() {
//    alert(checkedCustomer.join(','));
//}
